package qz_rpt

class PartProgressController {

    def dynamicQueryService
    def partProgress() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 100
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def partProgressSum=[]
        def tableHeadList=[]
        def partProgress=[]
        def list=[]
        def pageSizeList = [10,20,50,100]
        def totalCount =0
        def partProgressSumQty=[]
        params.SYS_QUERY_NAME = 'partProgressStepList'
        def partProgressStepList = dynamicQueryService.queryForList(params)

        if(params.EXPORT_CONTENT_NAME=='Excel'){
            params.SYS_QUERY_NAME = 'partProgress'
            partProgress = dynamicQueryService.queryForList(params)
            if (partProgress.size() > 0) {
                tableHeadList = partProgress[0].keySet()
            }
            params.SYS_QUERY_NAME = 'partProgressCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
            //list=TranposUtils.colToRow('STEP_NAME','STEP_QTY',partFinList)

//            params.SYS_QUERY_NAME = 'orderStatusAnalysisSum'
//            orderStatusAnalysisSum = dynamicQueryService.queryForList(params)
            params.SYS_QUERY_NAME = 'partProgressSumQty'
            partProgressSumQty = dynamicQueryService.queryForList(params)

        }
        print(tableHeadList)
        [startno:params.startno?:'',endno:params.endno?:'',pageSize     : pageSize, totalCount: totalCount, pageSizeList: pageSizeList,pageCurrent:pageCurrent,
         partProgressSum:partProgressSum,tableHeadList:tableHeadList,partProgress:partProgress,partProgressStepList:partProgressStepList,
         startTime:params.startTime,endTime:params.endTime,partName:params.partName,stepName:params.stepName,step:params.step?:'',
         stepDesc:params.stepDesc,group3:params.group3,partDesc:params.partDesc,docId:params.docId,
         totalGroup:params.totalGroup,detailCate:params.detailCate,partProgressSumQty:partProgressSumQty]
    }

    def partProgressStep() {
        def pageCurrent = params.pageCurrent ? Integer.parseInt(params.pageCurrent) : 1
        def pageSize = params.pageSize ? Integer.parseInt(params.pageSize) : 10
        params.startno = (pageSize * (pageCurrent - 1)) + 1
        params.endno = pageSize * pageCurrent
        def pageSizeList = [10,20,50,100]
        def tableHeadList=[]
        def partProgressStep=[]
        def totalCount=0
        def partProgressStepSumQty=[]

        if(params.state1=='WAIT'||params.state1=='RUN'||params.state1=='REPAIR'||params.state1=='FIN'||params.state1=='OUTSRC'){
            params.SYS_QUERY_NAME = 'partProgressStep'
            partProgressStep = dynamicQueryService.queryForList(params)
            if (partProgressStep.size() > 0) {
                tableHeadList = partProgressStep[0].keySet()
            }
            params.SYS_QUERY_NAME = 'partProgressStepCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
            params.SYS_QUERY_NAME = 'partProgressStepSumQty'
            partProgressStepSumQty = dynamicQueryService.queryForList(params)
        }else if(params.state1=='HOLD'){
            params.SYS_QUERY_NAME = 'partProgressStepHold'
            partProgressStep = dynamicQueryService.queryForList(params)
            if (partProgressStep.size() > 0) {
                tableHeadList = partProgressStep[0].keySet()
            }
            params.SYS_QUERY_NAME = 'partProgressStepHoldCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
            params.SYS_QUERY_NAME = 'partProgressStepHoldSumQty'
            partProgressStepSumQty = dynamicQueryService.queryForList(params)
        }else if(params.state1=='SCRAP'){
            params.SYS_QUERY_NAME = 'partProgressStepScrap'
            partProgressStep = dynamicQueryService.queryForList(params)
            if (partProgressStep.size() > 0) {
                tableHeadList = partProgressStep[0].keySet()
            }
            params.SYS_QUERY_NAME = 'partProgressStepScrapCount'
            totalCount = dynamicQueryService.queryForList(params)[0].TOTALCOUNT
            params.SYS_QUERY_NAME = 'partProgressStepScrapSumQty'
            partProgressStepSumQty = dynamicQueryService.queryForList(params)

        }



        [pageSize     : pageSize, totalCount: totalCount, pageSizeList: pageSizeList,pageCurrent:pageCurrent
         ,tableHeadList:tableHeadList,partProgressStep:partProgressStep,
         startTime:params.startTime,endTime:params.endTime,partName1:params.partName1,stepName1:params.stepName1,
        lotId:params.lotId,state1:params.state1,partProgressStepSumQty:partProgressStepSumQty]
    }

}
